package transactionimplementation

import (
	AbstractTransactions "SoftwareEngineering/AbstractTransactions"
	Model "SoftwareEngineering/Model"
	ModelImplementation "SoftwareEngineering/ModelImplementation"
	"reflect"
	DataBase "SoftwareEngineering/DataBase"
)

type ChangeUnaffiliatedTransaction struct {
	AbstractTransactions.ChangeAffiliationTransaction
}

func (c *ChangeUnaffiliatedTransaction) RecordMembership(employee *Model.employee) {
	af := employee.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation{}) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		memberId := uaf.GetMemberId()
		DataBase.PayrollDatabase.RemoveUnionMember(memberId)
	}
}

func (c *ChangeUnaffiliatedTransaction) GetAffiliation() Model.Affiliation {
	return Model.NoAffiliation{}
}
